www.gusucode.com > VC++ 新手写的简单客房管理系统源码程序 > VC++ 新手写的简单客房管理系统源码程序/code/tot/OutOpeDialog.cpp
//Download by http://www.NewXing.com // OutOpeDialog.cpp : implementation file // #include "stdafx.h" #include "tot.h" #include "OutOpeDialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // COutOpeDialog dialog COutOpeDialog::COutOpeDialog(CWnd* pParent /*=NULL*/) : CDialog(COutOpeDialog::IDD, pParent) { //{{AFX_DATA_INIT(COutOpeDialog) m_room = 0; m_radio = -1; m_name = _T(""); //}}AFX_DATA_INIT if(!m_dbase.Open(NULL,FALSE,FALSE,"ODBC;DSN=Room")) {AfxMessageBox("不能打开数据库");} m_ppset.Open(); } void COutOpeDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(COutOpeDialog) DDX_Text(pDX, IDC_OUTROOM, m_room); DDX_Radio(pDX, IDC_RADIO_HOUSE, m_radio); DDX_Text(pDX, IDC_NAME, m_name); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(COutOpeDialog, CDialog) //{{AFX_MSG_MAP(COutOpeDialog) ON_BN_CLICKED(IDC_RADIO_HOUSE, OnRadioHouse) ON_BN_CLICKED(IDC_RADIO_NAME, OnRadioName) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // COutOpeDialog message handlers void COutOpeDialog::OnOK() { // TODO: Add extra validation here CString mg; UpdateData(true); if(m_radio==-1) AfxMessageBox("请先选择退房的方式!"); else { if(m_radio==0) { try{ m_ppset.MoveFirst(); while(!m_ppset.IsEOF()) {if(m_ppset.m_roomID==m_room) break; else m_ppset.MoveNext(); } if(m_ppset.IsEOF()) AfxMessageBox("此房未住人!"); else{m_ppset.Delete(); // m_ppset.Update(); // m_ppset.Close(); AfxMessageBox("退房成功!"); } } catch(CDBException*pe) {AfxMessageBox(pe->m_strError); pe->Delete(); } } if(m_radio==1) { try{ m_ppset.MoveFirst(); while(!m_ppset.IsEOF()) {if(m_ppset.m_name==m_name) break; else m_ppset.MoveNext(); } if(m_ppset.IsEOF()) AfxMessageBox("记录中无此人!"); else{ m_ppset.Delete(); // m_ppset.Update(); // m_ppset.Close(); AfxMessageBox("退房成功!"); } } catch(CDBException*pe) {AfxMessageBox(pe->m_strError); pe->Delete(); } } // m_ppset.Update(); m_ppset.Close(); CDialog::OnOK(); } } void COutOpeDialog::OnRadioHouse() {CWnd *pWnd; // TODO: Add your control notification handler code here pWnd=GetDlgItem(IDC_OUTROOM); pWnd->EnableWindow(TRUE); GetDlgItem(IDC_OUTROOM)->SetFocus(); } void COutOpeDialog::OnRadioName() {CWnd *pWnd; // TODO: Add your control notification handler code here pWnd=GetDlgItem(IDC_NAME); pWnd->EnableWindow(TRUE); GetDlgItem(IDC_NAME)->SetFocus(); } BOOL COutOpeDialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here GetDlgItem(IDC_NAME)->EnableWindow(FALSE); GetDlgItem(IDC_OUTROOM)->EnableWindow(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }